package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceAppinfo;
import com.ruoyi.service.service.IServiceAppinfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * app信息Controller
 * 
 * @author ZDL
 * @date 2025-02-19
 */
@RestController
@RequestMapping("/service/appinfo")
public class ServiceAppinfoController extends BaseController
{
    @Autowired
    private IServiceAppinfoService serviceAppinfoService;

    /**
     * 查询app信息列表
     */
    @PreAuthorize("@ss.hasPermi('service:appinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceAppinfo serviceAppinfo)
    {
        startPage();
        List<ServiceAppinfo> list = serviceAppinfoService.selectServiceAppinfoList(serviceAppinfo);
        return getDataTable(list);
    }

    /**
     * 导出app信息列表
     */
    @PreAuthorize("@ss.hasPermi('service:appinfo:export')")
    @Log(title = "app信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceAppinfo serviceAppinfo)
    {
        List<ServiceAppinfo> list = serviceAppinfoService.selectServiceAppinfoList(serviceAppinfo);
        ExcelUtil<ServiceAppinfo> util = new ExcelUtil<ServiceAppinfo>(ServiceAppinfo.class);
        util.exportExcel(response, list, "app信息数据");
    }

    /**
     * 获取app信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:appinfo:query')")
    @GetMapping(value = "/{appinfoId}")
    public AjaxResult getInfo(@PathVariable("appinfoId") Long appinfoId)
    {
        return success(serviceAppinfoService.selectServiceAppinfoByAppinfoId(appinfoId));
    }

    /**
     * 新增app信息
     */
    @PreAuthorize("@ss.hasPermi('service:appinfo:add')")
    @Log(title = "app信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceAppinfo serviceAppinfo)
    {
        return toAjax(serviceAppinfoService.insertServiceAppinfo(serviceAppinfo));
    }

    /**
     * 修改app信息
     */
    @PreAuthorize("@ss.hasPermi('service:appinfo:edit')")
    @Log(title = "app信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceAppinfo serviceAppinfo)
    {
        return toAjax(serviceAppinfoService.updateServiceAppinfo(serviceAppinfo));
    }

    /**
     * 删除app信息
     */
    @PreAuthorize("@ss.hasPermi('service:appinfo:remove')")
    @Log(title = "app信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{appinfoIds}")
    public AjaxResult remove(@PathVariable Long[] appinfoIds)
    {
        return toAjax(serviceAppinfoService.deleteServiceAppinfoByAppinfoIds(appinfoIds));
    }
}
